<template>
  <div ref="myDiv" class="radar-echart"></div>
</template>

<script>
<<<<<<< HEAD
import { secondOne1Api, secondOne2Api } from "@/api/dashboard";
=======
>>>>>>> gxd
import * as Echarts from "echarts";
import Linechart from "./linechart";
import Linecharts from "./linecharts";
export default {
  name: "Linechart",
  data() {
    return {
      showIndex: "0",
<<<<<<< HEAD
      linedata1: [],
      linedata2: [],
=======
>>>>>>> gxd
    };
  },
  mounted() {
    this.echarts = Echarts.init(this.$refs.myDiv);
<<<<<<< HEAD
    this.initData();
    this.echarts.setOption(Linechart);
=======

    // this.initData();
    if (this.showIndex === "0") {
      this.echarts.setOption(Linechart);
    }
    if (this.showIndex === "1") {
      this.echarts.setOption(Linecharts);
    }
>>>>>>> gxd
  },
  watch: {
    showIndex(xin, jiu) {
      // console.log(xin, jiu);
      this.initData();
    },
  },
  methods: {
<<<<<<< HEAD
    async initData() {
      if (this.showIndex === "0") {
        let { dataline1 } = await secondOne1Api();
        // console.log(dataline1);
        this.linedata1 = dataline1;
        //重新绘制
        Linechart.series[0].data = this.linedata1[0].data;
        Linechart.series[1].data = this.linedata1[1].data;
        this.echarts.setOption(Linechart);
      }
      if (this.showIndex === "1") {
        let { dataline2 } = await secondOne2Api();
        this.linedata2 = dataline2;
        //重新绘制
        Linecharts.series[0].data = this.linedata2[0].data;
        Linecharts.series[1].data = this.linedata2[1].data;
=======
    initData() {
      if (this.showIndex === "0") {
        this.echarts.setOption(Linechart);
      }
      if (this.showIndex === "1") {
>>>>>>> gxd
        this.echarts.setOption(Linecharts);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.radar-echart {
  width: 865px;
  height: 295px;
}
</style>
